﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace StarLabel.label.item
{
    /// <summary>
    /// Copyright 2019  ZhengJi. All Rights Reserved.
    /// 文本标签定义
    /// </summary>
    public class TextItem:Item
    {
        public TextItem(XmlElement el) : base(el)
        {
        }

        public string FontName { get; set; }
        public string TextAlignment { get; set; }
       

        public string FontHeight { get; set; }
        public string FontStyle { get; set; }
        public string FontUnderLine { get; set; }
        
        protected override void parseFromXml()
        {
          
            this.FontName = this.xmlEl.Attributes["FontName"]==null?"宋体": this.xmlEl.Attributes["FontName"].Value;
             this.TextAlignment = this.xmlEl.Attributes["TextAlignment"]==null?"0": this.xmlEl.Attributes["TextAlignment"].Value;
            this.Rotation = this.xmlEl.Attributes["Rotation"]==null?"0": this.xmlEl.Attributes["Rotation"].Value;
            this.FontHeight = this.xmlEl.Attributes["FontHeight"]==null?"40": this.xmlEl.Attributes["FontHeight"].Value;
            this.FontStyle = this.xmlEl.Attributes["FontStyle"]==null?"2": this.xmlEl.Attributes["FontStyle"].Value;
            this.FontUnderLine = this.xmlEl.Attributes["FontUnderLine"]==null?"0": this.xmlEl.Attributes["FontUnderLine"].Value;
            this.Text = this.xmlEl.Attributes["Text"]==null?"": this.xmlEl.Attributes["Text"].Value;

            base.parseFromXml();
        }

        public override void DrawLabel(float x, float y, string labelText,string rotation)
        {
            // TSCPrint.windowsfont(StringUtil.string2Int(x.ToString()), StringUtil.string2Int(y.ToString()), StringUtil.string2Int(this.FontHeight), int.Parse(this.Rotation), StringUtil.string2Int(this.FontStyle), StringUtil.string2Int(this.FontUnderLine), this.FontName, labelText);

            TSCPrint.windowsfont(StringUtil.string2Int(x.ToString()), StringUtil.string2Int(y.ToString()), StringUtil.string2Int(this.FontHeight), int.Parse(rotation), StringUtil.string2Int(this.FontStyle), StringUtil.string2Int(this.FontUnderLine), this.FontName, labelText);
        }
    }
}
